# Maintainer: Pierre Schmitz <pierre@archlinux.de>
# Contributor: Alexandre Bique <bique.alexandre@gmail.com>

pkgname=hefur
pkgver=0.6
pkgrel=5
pkgdesc='A standalone and lightweight BitTorrent tracker'
arch=('x86_64')
url='http://github.com/abique/hefur'
license=('MIT')
makedepends=('git' 'cmake' 'docbook-xsl')
depends=('gnutls' 'xz' 'protobuf')
source=("git+https://github.com/abique/${pkgname}.git#tag=${pkgver}"
        'hefurd.service' 'tmpfiles.conf' 'sysusers.conf')
md5sums=('SKIP'
         '3107be29769b8afde3574dc6e31d5b6a'
         'b884385d6c87c350172427da4ba2688f'
         '7971708a1fe25c1b51e0a05e812f17c9')

prepare() {
	cd ${srcdir}/${pkgname}
	git submodule init
	git submodule update
	sed -i "s/PROJECT_NUMBER.*/PROJECT_NUMBER=${pkgver}/g" Doxyfile
}

build() {
	cd ${srcdir}/${pkgname}/manual
	xsltproc -o manual.html /usr/share/xml/docbook/xsl-stylesheets-*/html/docbook.xsl manual.xml

	cd ${srcdir}/${pkgname}
	mkdir build
	cd build
	cmake -DCMAKE_INSTALL_PREFIX=/usr ..
	make
}

package() {
	cd ${srcdir}/${pkgname}/build
	DESTDIR=${pkgdir} make install
	install -D -m644 ${srcdir}/hefurd.service ${pkgdir}/usr/lib/systemd/system/hefurd.service
	install -D -m644 ${srcdir}/tmpfiles.conf ${pkgdir}/usr/lib/tmpfiles.d/hefurd.conf
	install -D -m644 ${srcdir}/sysusers.conf ${pkgdir}/usr/lib/sysusers.d/hefurd.conf
	install -D -m644 ${srcdir}/${pkgname}/LICENSE ${pkgdir}/usr/share/licenses/hefur/LICENSE
}
